package com.zbxx.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.zbxx.domain.Product;
import com.zbxx.service.ProductService;

import javax.annotation.Resource;

//商品管理的action
public class ProductAction extends ActionSupport implements ModelDriven<Product>{
    //创建一个product的对象,方便模型驱动使用
    private Product product=new Product();
    //注入service
    @Resource
    private ProductService productService;
    @Override
    public Product getModel() {
        return product;
    }

    //保存商品
    public String save(){
        productService.save(product);
        return "saveSuccess";
    }
    public ProductService getProductService() {
        return productService;
    }

    public void setProductService(ProductService productService) {
        this.productService = productService;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }
}
